/**
 * @param {string} s
 * @param {number} numRows
 * @return {string}
 */
export var convert = function (s, numRows) {
  if (numRows === 1) return s
  const list = new Array(numRows)
  for (let i = 0; i < list.length; i++) {
    list[i] = []
  }

  let row = 0
  let col = 0
  let maxCol = 0
  for (let i = 0; i < s.length; i++) {
    list[row][col] = s[i]
    console.log('list[row][col] = s[i]', row, col, s[i])
    const mod = col % (numRows - 1)
    // console.log('mod', mod)
    if (mod === 0) {
      if (row + 1 > numRows - 1) {
        col++
        row--
      } else {
        row++
      }
    } else {
      row--
      col++
    }
    maxCol = Math.max(maxCol, col)
  }
  // console.log(list)
  // let res = ''
  // for (let i = 0; i < list.length; i++) {
  //   console.log(i, list[i])
  //   for (let j = 0; j <= maxCol; j++) {
  //     if (list[i][j]) {
  //       res += list[i][j]
  //     }
  //   }
  // }
  // return res
  return list.map(i => i.join('')).join('')
}
